#ifndef MSC_DATETIME_TIMES_H
#define MSC_DATETIME_TIMES_H

#include <stdbool.h>
#include <time.h>
#include "../pub.h"


CPUBLIC bool ms_time2tm(time_t t, struct tm* _Tm) {
#ifdef _WIN32
    errno_t er = localtime_s(_Tm, &t);
    return 0 == er;
#else
    return localtime_r(&t, _Tm) != NULL;
#endif
}

CPUBLIC time_t ms_localtime(struct tm* _Tm) {
    time_t t = time(NULL);
    ms_time2tm(t, _Tm);
    return t;
}

#endif // MSC_DATETIME_TIMES_H
